<template>
  <div class="searchIndex">
    <form action="/">
      <van-search
        v-model="value"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
      />
    </form>
    <div style="padding:10px 12px">
      <header class="hd">热门搜索</header>
      <nav class="list">
        <p :class="index<=1?'isActive':'listItem'" v-for="(item,index) in mylist" :key="index">{{item}}</p>
      </nav>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  name: "searchIndex",
  data() {
    return {
      value: "",
      mylist: [
        "省钱卡充9得45",
        "花呗十二期免息",
        "酒精",
        "猪肉",
        "拖鞋",
        "拖把",
        "酒精湿巾",
        "内裤",
        "化妆镜",
        "男士内裤",
        "电动牙刷",
        "午餐肉"
      ]
    };
  },
  methods: {
    onSearch(val) {
      Toast(val);
    },
    onCancel() {
      Toast("取消");
      this.$router.push({
        name: "classify"
      });
    }
  }
};
</script>

<style  scoped>
.searchIndex {
  height: 50%;
}
.hd {
  height: 1.2rem;
  font-size: 0.37333rem;
  color: #999;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  -moz-align-items: center;
  align-items: center;
}
.listItem {
  float: left;
  padding: 0 0.2rem;
  margin-right: 0.42667rem;
  margin-bottom: 0.42667rem;
  line-height: 0.61333rem;
  border: 1px solid #999;
  border-radius: 4px;
  color: #333;
}
.isActive {
  float: left;
  padding: 0 0.2rem;
  margin-right: 0.42667rem;
  margin-bottom: 0.42667rem;
  line-height: 0.61333rem;
  color: #dd1a21;
  border: 1px solid #dd1a21;
  border-radius: 4px;
}
</style>